



//
//  ThirdDetail.m
//  房源、商铺、写字楼详情页
//
//  Created by MB__Lee on 2018/5/22.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "ThirdDetail.h"

@interface ThirdDetail()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *RightDistance;

@property (weak, nonatomic) IBOutlet UILabel *rentType;  //方式 --对应内容：押二付一
@property (weak, nonatomic) IBOutlet UILabel *decoretationLabel; //装修--对应内容：中等装修
@property (weak, nonatomic) IBOutlet UILabel *oritationLabel; // 朝向---对应内容：朝东

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;  //时间---对应内容：2018-05-16
@property (weak, nonatomic) IBOutlet UILabel *floorLabel;  //楼层--对应内容：6/12 层

@property (weak, nonatomic) IBOutlet UILabel *numLabel;  // 编号 100048 所在label
@property (weak, nonatomic) IBOutlet UILabel *xq_Label; // ”小区详情“ 所在label
@property (weak, nonatomic) IBOutlet UILabel *xq_addressLabel;   //小区---对应内容：创业一村（共1套在租）



//商铺、写字楼的时候使用，，，显示“编号”，并且隐藏原来的编号
@property (weak, nonatomic) IBOutlet UILabel *doubleUse;//其实是朝向的那个label
//编号，当为商铺、写字楼的时候隐藏
@property (weak, nonatomic) IBOutlet UILabel *titleNumLabel; // 编号label

//

@end

@implementation ThirdDetail

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.RightDistance.constant = 0.5 * SCREEN_WIDTH;  //设置 时间、楼层、编号  第二列距离左边的距离
    
    UIButton *xq_detailBTN = [UIButton buttonWithType:UIButtonTypeCustom];
    xq_detailBTN.frame = CGRectMake(0, 0, MBScale(200), MBScale(100));
    xq_detailBTN.backgroundColor  =[UIColor clearColor];
    [xq_detailBTN addTarget:self action:@selector(pushInToXQDetail:) forControlEvents:UIControlEventTouchUpInside];
    
    
    xq_detailBTN.center = self.xq_Label.center;
    
    [self addSubview:xq_detailBTN];
    
    
}
-(void)setModel:(MBFangDetailModel *)model{
    [super setModel:model];
    
    //付租方式
    self.rentType.text = [NSString stringWithFormat:@"押%@/付%@",model.deposit_method,model.rent_method];
    
    // 时间
    NSString *time = [model.createtime substringWithRange:NSMakeRange(0, 10)];
    self.timeLabel.text = time;
    
    // 装修
    self.decoretationLabel.text = model.decoration;
    
    //楼层
    self.floorLabel.text = [NSString stringWithFormat:@"%@/%@层",model.floor,model.total_floor];
    
    //当为 住宅的时候为朝向 oritation，当为其他类型为type
    if ([model.category isEqualToString:@"1001"]) {
        self.oritationLabel.text = model.orientation;
        self.titleNumLabel.hidden = NO;
        self.numLabel.hidden = NO;
        self.doubleUse.text = @"朝向：";
    }else{
        self.titleNumLabel.hidden = YES;
        self.numLabel.hidden = YES;
        
        self.doubleUse.text = @"编号：";
        self.oritationLabel.text = model.sn;
    }
    
    //小区
    
    
    if (model.xq_zufang_num == nil) {
        return;
    }
    
    NSString *name = [NSString stringWithFormat:@"%@\n(共",model.xq_name];
    NSMutableAttributedString *att1 = [[NSMutableAttributedString alloc] initWithString:name attributes:@{NSFontAttributeName:MBFont(14),NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    NSMutableAttributedString *att2  =[[NSMutableAttributedString alloc] initWithString:model.xq_zufang_num attributes:@{NSForegroundColorAttributeName:MB_RGBA(255, 85, 85, 1.0)}];
    
    NSMutableAttributedString *att3 = [[NSMutableAttributedString alloc] initWithString:@"套在租）" attributes:@{NSFontAttributeName:MBFont(14),NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    
    [att1 appendAttributedString:att2];
    [att1 appendAttributedString:att3];
    
    self.xq_addressLabel.attributedText  = att1;
    
    
    
}
-(void)pushInToXQDetail:(UIButton *)btn{
   
    if (self.thirdBlock) {
        
        self.thirdBlock(self.model);
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
